﻿@using BK.Common.Web.UI.Models
@model CommonExpensesIndexModel
@using Telerik.Web.Mvc.UI

@{
	ViewBag.Title = "Витрати";
}

<script type="text/javascript">
	function edit(recordId)
	{
		var urlAction = "/CommonExpenses/Edit/" + recordId;
	    window.location.href = urlAction;
	}
	
	function del(id)
	{
	    alert(id);
	}
</script>

<h2>@ViewBag.Title</h2>

@(Html.Telerik().Grid(Model.Items).Name("Expenses")
		.HtmlAttributes(new {style = "width: 100%"})
		.Columns(columns =>
		{
			columns.Bound(o => o.Id).Width("75px");
			columns.Bound(o => o.Year).Width("75px");
			columns.Bound(o => o.Month).Width("75px");
			columns.Bound(o => o.Day).Width("75px");
			columns.Bound(o => o.Account).Width("100px");
			columns.Bound(o => o.Currency).Width("100px");
			columns.Bound(o => o.Category).Width("100px");
			columns.Bound(o => o.Amount).Width("100px");
			columns.Bound(o => o.Note);
            columns.Template(
                @<text>
                     <input type="button" class="t-button" value="Редагувати" onclick="edit(@item.Id)"/>
                 </text>
				).HtmlAttributes(new { @class = "command-column" });
			columns.Template(
				@<text>
                     <input type="button" class="t-button" value="Видалити" onclick="del(@item.Id)"/>
                 </text>
                ).HtmlAttributes(new { @class = "command-column" });

        })
		.Pageable(paging => 
            paging.PageSize(20)
                  .Style(GridPagerStyles.NextPreviousAndNumeric)
                  .Position(GridPagerPosition.Bottom))
		.Footer(true)
)
